package com.jfs.qy.enums;

import cn.hutool.core.util.EnumUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.LinkedHashMap;

/**
 * @Description 告警事件类型枚举
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/11/4
 */
@Getter
@AllArgsConstructor
public enum AlertEventEnum {

    /**
     * 普通抓拍
     */
    ORDINARY_SNAPSHOT("ORDINARY_SNAPSHOT", 0, "普通抓拍"),
    /**
     * 告警抓拍
     */
    ALARM_SNAPSHOT("ALARM_SNAPSHOT", 1, "告警抓拍"),
    /**
     * 口罩告警抓拍
     */
    MASK_ALARM_CAPTURE("MASK_ALARM_CAPTURE", 2, "口罩告警抓拍"),
    /**
     * 陌生人高频告警抓拍
     */
    STRANGER_HIGH_FREQUENCY_ALARM_CAPTURE("STRANGER_HIGH_FREQUENCY_ALARM_CAPTURE", 3, "陌生人高频告警抓拍"),
    /**
     * 名单库人员高频告警抓拍
     */
    SNAPSHOTS_OF_HIGH_FREQUENCY_ALARMS_FOR_PERSONNEL_IN_THE_LIST_DATABASE("SNAPSHOTS_OF_HIGH_FREQUENCY_ALARMS_FOR_PERSONNEL_IN_THE_LIST_DATABASE", 4, "名单库人员高频告警抓拍"),

    /**
     * 区域入侵告警
     */
    REGION_INVASION("Region Invasion", 5, "区域入侵"),
    /**
     * 区域进入告警
     */
    REGION_IN("Region In", 6, "区域进入"),
    /**
     * 镜头遮挡告警
     */
    LENS("Lens", 7, "镜头遮挡"),
    /**
     * 声音告警
     */
    SOUND("Sound", 8, "声音告警"),
    /**
     * 口罩告警
     */
    MASK("Mask", 9, "口罩告警"),
    /**
     * 排队告警
     */
    QUEUE("Queue", 10, "排队告警"),
    /**
     * 人群密度告警
     */
    PEOPLE_DENSITY("People Density", 11, "人群密度告警"),
    /**
     * 过线统计告警
     */
    PEOPLE_COUNT("People Count", 12, "过线统计告警"),
    /**
     * 越线报警
     */
    OVER_LIN("Over Lin", 13, "越线报警"),
    /**
     * 区域离开告警
     */
    REGION_OUT("Region Out", 14, "区域离开告警"),
    /**
     * 快速移动告警
     */
    FAST_MOVE("Fast Move", 15, "快速移动告警"),
    /**
     * 徘徊检测告警
     */
    LINGER("Linger", 16, "徘徊检测告警"),
    /**
     * 第三方算法告警
     */
    THIRD_PART_ALOG("Third Part Alog", 17, "第三方算法告警"),
    /**
     * 物品遗留告警
     */
    ITEM_LEAVE("Item Leave", 18, "物品遗留告警"),
    /**
     * 物品移走告警
     */
    ITEM_MOVE("Item Move", 19, "物品移走告警"),
    /**
     * 电瓶车告警
     */
    ELECTROMOBILE("Electromobile", 20, "电瓶车告警"),
    /**
     * 违法停车告警
     */
    ILLEGALP_PARKING("Illegalp Parking", 21, "违法停车告警"),
    /**
     * 离岗检测告警
     */
    LEAVE_DETECT("Leave_detect", 22, "离岗检测告警"),
    /**
     * 过线统计实时数据
     */
    CROSS_COUNTING("cross_counting",23,"过线统计实时数据"),
    /**
     * 排队长度实时数据
     */
    QUEUE_LENGTH("queue_length",24,"排队长度实时数据"),
    /**
     * 人群密度实时数据
     */
    CROWD_DENSITY("crowd_density",25,"人群密度实时数据");
    /**
     * 告警名称
     */
    private final String name;
    /**
     * 类型
     */
    private final Integer code;
    /**
     * 描述
     */
    private final String describe;

    /**
     * 根据code获取枚举
     *
     * @param code
     * @return
     */
    public static AlertEventEnum getEnumByCode(Integer code) {
        LinkedHashMap<String, AlertEventEnum> enumMap = EnumUtil.getEnumMap(AlertEventEnum.class);
        for (String key : enumMap.keySet()
        ) {
            AlertEventEnum alertEventEnum = enumMap.get(key);
            if (code.equals(alertEventEnum.getCode())) {
                return alertEventEnum;
            }
        }
        return null;
    }

    /**
     * 根据name 获取枚举
     *
     * @param name
     * @return
     */
    public static AlertEventEnum getEnumByName(String name) {
        LinkedHashMap<String, AlertEventEnum> enumMap = EnumUtil.getEnumMap(AlertEventEnum.class);
        for (String key : enumMap.keySet()
        ) {
            AlertEventEnum alertEventEnum = enumMap.get(key);
            if (name.equals(alertEventEnum.getName())) {
                return alertEventEnum;
            }
        }
        return null;
    }
}
